import Vue from 'vue'
import soocStorage from '../util/localStorage'

// let baseUrl = 'http://172.16.14.113/dzjg/index.php';
let baseUrl = 'http://172.16.14.113/soocadv/restful/web/index.php';
let version = '/v1';

export const actions = {
  //与后端接口进行交互
  doLogin(store) {
    let params = {
      cellphone:'1866005xxxx',
      password:'haiyan.com'
    };
    Vue.axios.post(baseUrl+'/site/login',params).then((response) => {
      console.log(response.data);
      let user = soocStorage.wrapJsonStorage('user_token');
      user.remove('user_token')
      user.set('oauth_token', response.data.access_token).set('expired_at',response.data.expired_at).save();
    });
  },
  //获取首页课程列表
  getCourseList(store) {
    Vue.axios.get(baseUrl+version+'/user').then((response) => {
      store.commit('get_course_list', response.data.data);
    });
  }
}

export default actions